package com.dss.sdk.api.client;

import com.dss.sdk.api.base.BaseApi;
import com.dss.sdk.api.req.*;
import com.dss.sdk.api.resp.*;
import com.dss.sdk.api.service.DssClientService;
import com.dss.sdk.constants.ApiUrlConstants;
import com.dss.sdk.exception.ApiException;
import com.dss.sdk.response.DssResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Fadada
 */
public class FileSignClient extends BaseApi {

    public FileSignClient(DssClientService clientService) {
        super(clientService);
    }

    /**
     * POST /fileSign/sign : 文件签署
     * 接口说明：对文件进行电子签名，支持把需要加盖的电子签名及证书，加盖到指定的签署位置。支持电子印章、日期章、骑缝章及签署备注。 适用场景：对最终确认签署的电子文件（PDF/OFD）进行电子签名。
     *
     * @param fileSignSignRequest (optional)
     * @return 成功 (status code 200)
     */
    public DssResponse<FileSignSignResponse> fileSignSign(FileSignSignRequest fileSignSignRequest) throws ApiException {
        return clientService.execute(fileSignSignRequest, ApiUrlConstants.fileSignSign, FileSignSignResponse.class);
    }

    /**
     * POST /api/file/sign/across : 骑缝章签署
     *
     * @param fileSignSignRequest
     * @return
     */
    public DssResponse<FileSignSignResponse> fileSignAcross(FileSignSignRequest fileSignSignRequest) throws ApiException {
        return clientService.execute(fileSignSignRequest, ApiUrlConstants.fileSignAcross, FileSignSignResponse.class);
    }

    /**
     * POST /api/file/sign/remark : 备注签署
     *
     * @param fileSignSignRequest
     * @return
     */
    public DssResponse<FileSignSignResponse> fileSignRemark(FileSignSignRequest fileSignSignRequest) throws ApiException {
        return clientService.execute(fileSignSignRequest, ApiUrlConstants.fileSignRemark, FileSignSignResponse.class);
    }


    /**
     * POST /api/file/sign/batch : 批量文件签署
     */
    public DssResponse<FileBatchSignResponse> fileSignBatch(FileBatchSignRequest batchSignRequest) throws ApiException {
        return clientService.execute(batchSignRequest, ApiUrlConstants.fileSignBatch, FileBatchSignResponse.class);
    }

    /**
     * 查询文件签署记录
     */
    public DssResponse<FileSignListResponse> fileSignList(FileSignListRequest request) throws ApiException {
        return clientService.execute(request, ApiUrlConstants.fileSignList, FileSignListResponse.class);
    }

    /**
     * EUI-获取文件预览页
     */
    public DssResponse<FilePreviewUrlResponse> filePreviewUrl(FilePreviewUrlRequest previewUrlRequest) throws ApiException {
        return clientService.execute(previewUrlRequest, ApiUrlConstants.filePreviewUrl, FilePreviewUrlResponse.class);
    }

    public DssResponse<FileSignUrlResponse> fileSignUrl(FileSignUrlRequest request) throws ApiException {
        return clientService.execute(request, ApiUrlConstants.fileSignUrl, FileSignUrlResponse.class);
    }

    public DssResponse<FileSignVerifyResponse> fileSignVerify(FileSignVerifyRequest request) throws ApiException {
        return clientService.execute(request, ApiUrlConstants.fileSignVerify, FileSignVerifyResponse.class);
    }
}
